#

| Chapter 43 Printing |

## 43.13 The Text Formatters nroff, troff, ditroff, ...

Have you used a WYSIWYG (What You See Is What You Get) desktop publishing program like FrameMaker, WordPerfect, Interleaf, and so on? Then you might not have much experience with the original UNIX formatters, nroff and troff.

Instead of showing a picture of the completed document on your screen as you type, these formatters read a source file full of text and special formatting commands. The formatted output goes into a file (text, PostScript, or some other format) or straight to a printer. You create and edit the source file with any text editor (like vi). O'Reilly & Associates still uses troff to produce many of its books. For example, the start of the source file for this article looks like:

>     .Ah 2520 "The Text Formatters nroff, troff, ditroff, ..."
>     Have you used a WYSIWYG (What You See Is What You Get) desktop
>     publishing program  like FrameMaker, WordPerfect, Interleaf and so on?
>     Then you might not have much experience with the original UNIX
>     formatters, \fInroff\fP and \fItroff\fP.
>     .LP
>     Instead of showing a picture of the completed document on your
>     screen as you type, these formatters read a \fIsource file\fP full
>     ...

You might wonder, "Why use these dinosaurs?"

- All UNIX systems have them or can get them, so they're portable.

- The source files are usually much smaller than WYSIWYG formatters' files.

- The source files are plain text with no non-printable characters; they're easy to copy from one system to another. For instance, I work on books on my DOS laptop, then transfer the files to UNIX for formatting.

- The formatting language that's used has a powerful set of features that gives professional typesetters (like O'Reilly & Associates) excellent control over the way the output page looks.

- You can use UNIX utilities-grep, awk, shell scripts, and many others - to process the text. This adds even more power to the formatting setup. For example, that `2520` following the `.Ah` in the example above is the filename. Each article in this book has an arbitrary four digit filename; this is mapped into the section number printed in the margin and in all the cross references throughout the book using a system of scripts I wrote. I also built a crude outline processor so that we could control the organization of the book by changing a single file. All this was possible only because troff wasn't forced to work alone - we could apply the full power of the UNIX environment.

Batch formatters like nroff and troff aren't the answer for all formatting jobs, but they're worth looking into - especially for small or very complex jobs.

- JP

43.12 Typesetting Overview |  | 43.14 nroff/troff and Macro Packages